# -*- coding: utf-8 -*-
"""
-------------------------------------------------
   File Name：   __init__.py
   Author :      wuqianyong
   date：        2019/3/13
-------------------------------------------------
   Change Activity:
                   2017/4/1:
-------------------------------------------------
Description :
验证码识别

"""
__author__ = 'wuqianyong'
import base64
import requests
import os
import json

# url = "http://kerlomz.xyi.asia:19972/captcha/v1"
# url = "http://127.0.0.1:19953/captcha/v1"
url = "http://43.243.85.114:19953/captcha/v1"
# url = "http://47.102.108.8/captcha/v1"
# url = "http://www.wuqianyong.com/captcha/v1"


def get_captcha_data(img_path):
    # 读取图片为 base64
    f = open(img_path, 'rb')
    base64_data = base64.b64encode(f.read())
    f.close()
    data = {"image": base64_data}
    # base64.b64decode(base64data)
    # print(base64_data)
    req = requests.post(url=url, data=data)
    return json.loads(req.text)


if __name__ == '__main__':

    print(get_captcha_data(r'D:\zhongan\data\Patchca_Trains\2mgn_fb6f3bb45442a0a137dbaf55357e51ce.jpg'))